import {defineConfig} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import path from 'path'

export default defineConfig({
    plugins: [
        uni(),
        // 自动导入 Vue 相关函数（如 ref、reactive 等）和 uni-app API
        AutoImport({
            resolvers: [ElementPlusResolver()],
            imports: ['vue', 'uni-app']
        }),
        // 自动导入组件和 Element Plus 样式
        Components({
            resolvers: [
                ElementPlusResolver({
                    importStyle: 'css', // 启用 CSS 样式按需导入
                    directives: true // 自动导入 Element Plus 指令（如 v-loading）
                })
            ]
        })
    ],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'src')
        }
    }
})
